#ifndef GLO_TEST_H
#define GLO_TEST_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include "/usr/lib/mpich/include/mpi.h"
#include <mpi.h>
//"/home/00292431309/Desktop/mpich-1.2.7p1/include/mpi.h"

int drinking = 0;
int requested = 0;

int** holds_bottle = 0; // Que garrafas esta segurando.
int* holds_turn = 0; // Que turno esta conosco.
int** owes_bottle = 0; // Que garrafa eu devo.
int needs_bottle = 0; // Que garrafa eu quero
int old_needs_bottle = 0;
int** requested_bottle = 0; // Que garrafas foram pedidas.


int i, j, parent = -1, neighca = 0, *neighva, ranka, cont=0;
struct msgstruct {
	int request_bottle; // If -1 no bottle requested
	int turn; // If -1 no turn sent
	int bottle; // If -1 no bottle sent

};
int blocklengths[3]= { sizeof(int), sizeof(int), sizeof(int) };
MPI_Datatype types[3] = { MPI_INT, MPI_INT, MPI_INT };

int type_index;
void giveAllBottles();
void requestBottles();
void processMsgs();
int findNeighbor(int);
void printHoldBottle();
void addMsg(int request_bottle, int turn, int bottle, int who); 
void sendMsgs(int *msgc, int **destv, void **msgv, int **type_msgv); 
struct msgstruct *createMsgv(int tam);

struct msgInfo {
	struct msgstruct* msg;
	int sender;
};

#endif
